package com.tich.program.controller;


import com.tich.constant.ResponseMessageConstant;
import com.tich.program.domain.dto.CategoryDeleteDTO;
import com.tich.program.domain.dto.CategorySaveDTO;
import com.tich.program.domain.vo.ProgramCategoryVO;
import com.tich.program.service.IProgramCategoryService;
import com.tich.result.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

import java.util.List;

/**
 * 节目种类接口
 * */
@Slf4j
@RestController
@RequestMapping("/program/category")
public class ProgramCategoryController {

    @Autowired
    private IProgramCategoryService iProgramCategoryService;

    /**
     * 查询所有节目种类
     * @return
     * */
    @GetMapping
    public Result<List<ProgramCategoryVO>> queryProgramCategory(){
        log.info("查询所有节目的种类");
        return Result.success(ResponseMessageConstant.QUERY_SUCCESS, iProgramCategoryService.queryProgramCategory());

    }

    /**
     * 批量新增节目种类
     * @param categorySaveDTO
     * @return
     * */
    @PostMapping
    public Result addProgramCategorys(@RequestBody CategorySaveDTO categorySaveDTO){
        //TODO 添加用户身份判断是不是管理员
        log.info("批量新增节目种类：{}", categorySaveDTO.toString());
        iProgramCategoryService.addBatch(categorySaveDTO);
        return Result.success(ResponseMessageConstant.SAVE_SUCCESS);
    }

    /**
     * 批量删除节目种类
     * @param categoryDeleteDTO
     * @return
     * */
    @DeleteMapping
    public Result deleteProgramCategorys(@RequestBody CategoryDeleteDTO categoryDeleteDTO){
        //TODO 添加用户身份判断是不是管理员
        log.info("批量删除节目种类：{}", categoryDeleteDTO.toString());
        iProgramCategoryService.deleteProgramCategorys(categoryDeleteDTO);
        log.info("结束业务");
        return Result.success(ResponseMessageConstant.DELETE_SUCCESS);
    }

}
